﻿#pragma once

namespace Hazal
{
	enum class EFramebufferTextureFormat
	{
		None = 0,

		/// Color
		RGBA8,
		RED_INTEGER,

		/// Depth/Stencil
		DEPTH24STENCIL8,	

		/// Default
		Depth = DEPTH24STENCIL8,
	};


	struct SFramebufferTextureSpecification
	{
		SFramebufferTextureSpecification() = default;

		SFramebufferTextureSpecification(EFramebufferTextureFormat format) 
			: m_eFormat(format){}

		EFramebufferTextureFormat m_eFormat;
	};

	struct SFramebufferAttachmentSpecification
	{
		SFramebufferAttachmentSpecification() = default;

		SFramebufferAttachmentSpecification(std::initializer_list<SFramebufferTextureSpecification> attachments)
			:m_vecAttachments(attachments){}

		std::vector<SFramebufferTextureSpecification> m_vecAttachments;
	};

	struct SFrameBufferSpecification
	{
		uint32_t m_unWidth;
		uint32_t m_unHeight;
		uint32_t m_unSamples = 1; 

		SFramebufferAttachmentSpecification m_attachments;

		bool m_bSwapChainTarget = false;
	};

	class CFrameBuffer
	{
	public:
		virtual ~CFrameBuffer() = default;

	public:
		virtual SFrameBufferSpecification& GetSpecification() = 0;

		virtual const SFrameBufferSpecification& GetSpecification() const = 0;

		virtual uint32_t GetColorAttachmentRendererID(int32_t nIndex = 0) const = 0;

		virtual int ReadPixel(uint32_t unAttachmentIndex, int x, int y) = 0;

		virtual void ClearAttachment(uint32_t unAttachmentIndex, int nValue) const = 0;

		virtual void Bind() = 0;

		virtual void Unbind() = 0;

		virtual void Resize(uint32_t unWidth, uint32_t unHeight) = 0;

	public:
		static Ref<CFrameBuffer> Create(const SFrameBufferSpecification& spec);
	};

}
